﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZeldoEngineObjects.Maps;
using System.IO;
using ZeldoEngineServices.Maps;
using System.Data;
using ZeldoEngineObjects;
using ZeldoEngineObjects.Database;

namespace ZeldoEngine.Ressources.Chipsets
{
    public class RessourceChipsets
    {
        public List<Chipset> Chipsets { get; set; }

        public RessourceChipsets()
        {
            this.Chipsets = new List<Chipset>();
        }

        public void ChargerRessources(string chipsetDir)
        {
            if (Directory.Exists(chipsetDir))
            {
                this.Chipsets = SqlChipset.LireChipset();
            }
        }

        public Chipset LireChipset(string p)
        {
            foreach (var c in this.Chipsets)
            {
                if (c.Nom.Equals(p, StringComparison.InvariantCultureIgnoreCase))
                {
                    return c;
                }
            }

            return null;
        }

        public void EnregistrerChipsets(List<Chipset> chipsets)
        {
            foreach (var c in chipsets)
            {
                SqlChipset.EffacerChipset(c);
                SqlChipset.EnregistrerChipset(c);
            }
        }
    }
}
